package fr.musique.bean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "T_UTILISATEUR")
public class Utilisateur implements Serializable {

	private static final long serialVersionUID = 2090062595259665361L;

	public static enum Langue {
		FR("FR"), EN("EN"), IT("IT"), PL("PL");

		protected String langue;

		Langue(String langue) {
			this.langue = langue;
		}

		public String getLangue() {
			return this.langue;
		}
	}

	public static enum ReseauSociaux {
		FACEBOOK("facebook"), TWITER("twiter");

		protected String reseau;

		ReseauSociaux(String reseau) {
			this.reseau = reseau;
		}

		public String getReseau() {
			return this.reseau;
		}

	}

	private int id;

	private String nom;

	private String prenom;

	private String password;

	private String email;

	private String webSite;

	private String description;

	private Langue langue;

	private ReseauSociaux reseau;

	private List<Playlist> playlists;

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue
	@Column(name = "UTILISATEUR_ID")
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the nom
	 */
	@Column
	public String getNom() {
		return nom;
	}

	/**
	 * @param nom
	 *            the nom to set
	 */
	public void setNom(String nom) {
		this.nom = nom;
	}

	/**
	 * @return the prenom
	 */
	@Column
	public String getPrenom() {
		return prenom;
	}

	/**
	 * @param prenom
	 *            the prenom to set
	 */
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	/**
	 * @return the email
	 */
	@Column
	public String getEmail() {
		return email;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the webSite
	 */
	@Column
	public String getWebSite() {
		return webSite;
	}

	/**
	 * @param webSite
	 *            the webSite to set
	 */
	public void setWebSite(String webSite) {
		this.webSite = webSite;
	}

	/**
	 * @return the description
	 */
	@Column
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the langue
	 */
	@Column
	public Langue getLangue() {
		return langue;
	}

	/**
	 * @param langue
	 *            the langue to set
	 */
	public void setLangue(Langue langue) {
		this.langue = langue;
	}

	/**
	 * @return the reseau
	 */
	@Column
	public ReseauSociaux getReseau() {
		return reseau;
	}

	/**
	 * @param reseau
	 *            the reseau to set
	 */
	public void setReseau(ReseauSociaux reseau) {
		this.reseau = reseau;
	}

	/**
	 * @return the password
	 */
	@Column
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the playlists
	 */
	// Jointure entre la table playlist et utilisateur afin de pouvoir renvoyer
	// la
	// liste des playlists appartenant à l'utilisateur
	@OneToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "UTILISATEUR_PLAYLIST", joinColumns = { @JoinColumn(name = "UTILISATEUR_ID") }, inverseJoinColumns = { @JoinColumn(name = "PLAYLIST_ID") })
	public List<Playlist> getPlaylists() {
		return playlists;
	}

	/**
	 * @param playlists
	 *            the playlists to set
	 */
	public void setPlaylists(List<Playlist> playlists) {
		this.playlists = playlists;
	}

}
